package com.czx.task.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.cloud.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.czx.task.dao.TaskDao;
import com.czx.task.domain.dto.TaskDTO;
import com.czx.task.domain.entity.Task;
import com.czx.task.domain.vo.TaskVO;
import com.czx.task.mapper.TaskMapper;
import com.czx.task.service.TaskService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService {

    @Resource
    private TaskDao taskDao;

    @Override
    public List<TaskVO> getList(TaskDTO dto) {
        QueryWrapper<Task> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(StringUtils.isNotEmpty(dto.getTitle()),"title", dto.getTitle());
        queryWrapper.like(StringUtils.isNotEmpty(dto.getDescription()),"description", dto.getDescription());
        return BeanUtil.copyToList(list(queryWrapper), TaskVO.class);
    }

}
